package com.jane.adapter.hostheadlinesadapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jane.bean.PlatformDetailBean;
import com.jane.gzzb.R;
import com.jane.utils.Utils;

import org.xutils.common.util.MD5;

import java.util.ArrayList;

/**
 * Created by Grace on 2016/11/15.
 */

public class PlatformDetailAdapter extends BaseAdapter {
    private ArrayList<PlatformDetailBean.CommentatorsBean.GameinfoBean> mData;
    private Context mContext;



    public PlatformDetailAdapter(ArrayList<PlatformDetailBean.CommentatorsBean.GameinfoBean> mData, Context mContext) {
        this.mData = mData;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return mData==null?0:mData.size();
    }

    @Override
    public Object getItem(int i) {
        return mData.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view==null){
            view=View.inflate(mContext,R.layout.platformdetail_item,null);
            holder=new ViewHolder(view);
            view.setTag(holder);
        }else {
            holder= (ViewHolder) view.getTag();
        }
        Utils.loadImage(holder.mImageView,mData.get(i).getRawcoverimage());
        holder.mTvName.setText(mData.get(i).getName());
        holder.mTvCount.setText(mData.get(i).getViewers()+"");
        holder.mTvTitle.setText(mData.get(i).getTitle());
        holder.mTvCommentator.setText(mData.get(i).getSourcename()+" ﹒ "+ mData.get(i).getCommentator());
        return view;
    }
    public static class ViewHolder{
        private ImageView mImageView;
        private TextView mTvTitle,mTvName,mTvCount,mTvCommentator;
        public ViewHolder(View itemView){
            mImageView= (ImageView) itemView.findViewById(R.id.iv_item_detail);
            mTvCommentator= (TextView) itemView.findViewById(R.id.tv_item_commentator);
            mTvCount= (TextView) itemView.findViewById(R.id.tv_item_count);
            mTvName= (TextView) itemView.findViewById(R.id.tv_name_detail);
            mTvTitle= (TextView) itemView.findViewById(R.id.tv_item_title);
        }
    }
}
